module.exports = {
  tendencyKongBuySellNormal () {
    const dayEmaInfo = this.btbItem.dayEmaInfo || {}
    const hourEmaInfo = this.btbItem.hourEmaInfo || {}
    const hour4EmaInfo = this.btbItem.hour4EmaInfo || {}
    const minute15EmaInfo = this.btbItem.minute15EmaInfo || {}
    // if (dayEmaInfo.isLongKong && this.btbIndexTotalInfo.positionFen < -50) {
    //   if (
    //     (dayEmaInfo.isKdjDecline || dayEmaInfo.isMacdDecline) &&
    //     hourEmaInfo.isKong && minute15EmaInfo.isKong
    //   ) {
    //     this.setSell('tendencyKongBuySellNormal-1')
    //   }
    // } else {
    //
    // }
    // 按小时线做空
    if (
      (hourEmaInfo.ema10 < hourEmaInfo.ema20 && hourEmaInfo.ema5 < hourEmaInfo.ema20) &&
      (hourEmaInfo.isKdjDecline || hourEmaInfo.isMacdDecline) &&
      (hourEmaInfo.macd < 0 || hourEmaInfo.kdjDiff < 0)
    ) {
      if (
        !dayEmaInfo.isDuo &&
        hourEmaInfo.isKdjDecline && hourEmaInfo.isMacdDecline &&
        minute15EmaInfo.kdjDiff < 0 &&
        minute15EmaInfo.isKong &&
        (minute15EmaInfo.isKdjDecline && minute15EmaInfo.isMacdDecline) &&
        !(hour4EmaInfo.isLongDuo && dayEmaInfo.ema5 > dayEmaInfo.ema10 && dayEmaInfo.macd > 0)
      ) {
        this.setSell('tendencyKongBuySellNormal-2')
      }
    } else if (
      (dayEmaInfo.isKdjDecline && dayEmaInfo.isMacdDecline) &&
      hour4EmaInfo.isLongKong &&
      (hour4EmaInfo.isKdjDecline || hour4EmaInfo.isMacdDecline) &&
      hourEmaInfo.isLongKong
    ) {
      if (
        !dayEmaInfo.isDuo &&
        minute15EmaInfo.kdjDiff < 0 &&
        minute15EmaInfo.isKong &&
        (minute15EmaInfo.isKdjDecline && minute15EmaInfo.isMacdDecline)
      ) {
        this.setSell('tendencyKongBuySellNormal-3')
      }
    } else {
      if (minute15EmaInfo.kdjDiff > 0 && (minute15EmaInfo.macd > 0 || minute15EmaInfo.ema5 > minute15EmaInfo.ema10)) {
        // 按天持有太能亏了
        this.setPingKong('tendencyKongBuySellNormal-101')
      }
    }
    // 不做多
    this.buy = false
    this.buyReason = ''
    if (this.hasDuoPosition) {
      this.setPingDuo('tendencyKongBuySellNormal-201')
    }
  },
  weekKongBuySellNormal () {
    const {
      isHourAndHour4SgOK
    } = this.indexFlagInfo
    const dayEmaInfo = this.btbItem.dayEmaInfo || {}
    const hour4EmaInfo = this.btbItem.hour4EmaInfo || {}
    const hourEmaInfo = this.btbItem.hourEmaInfo || {}
    const minute15EmaInfo = this.btbItem.minute15EmaInfo || {}
    if (
      (dayEmaInfo.isKdjIncrease && dayEmaInfo.isMacdIncrease && !dayEmaInfo.isDownLikeL) &&
      (hour4EmaInfo.isKdjIncrease && hour4EmaInfo.isMacdIncrease && !hour4EmaInfo.isDownLikeL) &&
      hourEmaInfo.isLongDuo &&
      (hourEmaInfo.isKdjIncrease || hourEmaInfo.isMacdIncrease)
    ) {
      if (hourEmaInfo.isKdjIncrease && hourEmaInfo.isMacdIncrease) {
        if (
          !dayEmaInfo.isDuo &&
          minute15EmaInfo.kdjDiff > 0 &&
          isHourAndHour4SgOK &&
          minute15EmaInfo.sg > 0.8 &&
          minute15EmaInfo.isDuo &&
          (minute15EmaInfo.isKdjIncrease && minute15EmaInfo.isMacdIncrease)
        ) {
          this.setBuy('weekKongBuySellNormal-1')
        }
      }
      if (minute15EmaInfo.kdjDiff > 0 && (minute15EmaInfo.macd > 0 || minute15EmaInfo.ema5 > minute15EmaInfo.ema10)) {
        this.setPingKong('weekKongBuySellNormal-101')
      }
    } else {
      if (this.hasDuoPosition) {
        this.setPingDuo('weekKongBuySellNormal-201')
      }
      if (
        (dayEmaInfo.isLongKong && hour4EmaInfo.isLongKong && !dayEmaInfo.isDownLikeL && !hour4EmaInfo.isDownLikeL) &&
        (hourEmaInfo.isLongKong && (hourEmaInfo.isKdjDecline || hourEmaInfo.isMacdDecline))
      ) {
        if (
          !dayEmaInfo.isDuo &&
          (hourEmaInfo.isKdjDecline && hourEmaInfo.isMacdDecline) &&
          minute15EmaInfo.isKong &&
          (minute15EmaInfo.kdjDiff < 0 && minute15EmaInfo.sg > 0.8) &&
          (minute15EmaInfo.isKdjDecline && minute15EmaInfo.isMacdDecline)
        ) {
          this.setSell('weekKongBuySellNormal-2')
        }
      } else if (
        (dayEmaInfo.isKong && hour4EmaInfo.isKong) &&
        (hourEmaInfo.isLongKong && (hourEmaInfo.isKdjDecline || hourEmaInfo.isMacdDecline))
      ) {
        if (
          !dayEmaInfo.isDuo &&
          (hourEmaInfo.isKdjDecline && hourEmaInfo.isMacdDecline) &&
          minute15EmaInfo.isKong &&
          (minute15EmaInfo.kdjDiff < 0 && minute15EmaInfo.sg > 0.8) &&
          (minute15EmaInfo.isKdjDecline && minute15EmaInfo.isMacdDecline)
        ) {
          this.setSell('weekKongBuySellNormal-3')
        }
      } else if (
        (dayEmaInfo.ema5 < dayEmaInfo.ema10 && dayEmaInfo.macd < 0 && dayEmaInfo.kdjDiff < 0 && dayEmaInfo.isAllDecline) &&
        (hour4EmaInfo.isKong && hour4EmaInfo.isAllDecline && hour4EmaInfo.days5RealWave > 0.2 && hour4EmaInfo.days5MaxWave > 0.2) &&
        (hourEmaInfo.isKong && hourEmaInfo.isAllDecline && hourEmaInfo.macddd > 1)
      ) {
        if (
          minute15EmaInfo.isAllDecline && minute15EmaInfo.isKong
        ) {
          this.setSell('weekKongBuySellNormal-4')
        }
      } else {
        if (minute15EmaInfo.kdjDiff > 0 && (minute15EmaInfo.macd > 0 || minute15EmaInfo.ema5 > minute15EmaInfo.ema10)) {
          this.setPingKong('weekKongBuySellNormal-102')
        }
      }
    }
  }
}
